package xyf.p11.other;

/**
 * ClassName: P0240_SearchMatrix
 * Description:
 * Author: xyf
 * Date: 9/16/22 10:39 PM
 * Version: 1.0
 **/
public class P0240_SearchMatrix
{
    public boolean searchMatrix(int[][] matrix, int target)
    {
        int row = 0;
        int col = matrix[0].length - 1;
        while (row < matrix.length && col >= 0)
        {
            if (matrix[row][col] == target)
            {
                return true;
            }
            else if (matrix[row][col] < target)
            {
                row++;
            }
            else
            {
                col--;
            }
        }
        return false;
    }
}